//
//  OrderMsgCell.m
//  JiongTu
//
//  Created by 杨璟 on 16/4/1.
//  Copyright © 2016年 YSKJ. All rights reserved.
//

#import "OrderMsgCell.h"

#import "JTDriverTrip.h"
#import "JTPassengerTrip.h"
#import "UIView+Extension.h"
#import "JTUser.h"

#import <AVOSCloud.h>
#import "UIImageView+WebCache.h"

@interface OrderMsgCell ()

@property (weak, nonatomic) IBOutlet UIImageView *userIcon;
@property (weak, nonatomic) IBOutlet UILabel *nameLabel;
@property (weak, nonatomic) IBOutlet UILabel *startLabel;
@property (weak, nonatomic) IBOutlet UILabel *endLabel;
@property (weak, nonatomic) IBOutlet UILabel *timeType;
@property (weak, nonatomic) IBOutlet UILabel *timeLabel;

@end

@implementation OrderMsgCell

- (void)layoutSubviews {
    [super layoutSubviews];
    
    //固定为storyboard中宽度的一半
    self.userIcon.layer.cornerRadius = 28;
    self.userIcon.layer.masksToBounds = YES;
    self.userIcon.layer.borderWidth = 1;
    self.userIcon.layer.borderColor = [[UIColor lightGrayColor] CGColor];
}

- (void)setTrip:(id)trip {
    _trip = trip;
    
    if ([trip isKindOfClass:[JTPassengerTrip class]]) {
        JTPassengerTrip *passengerTrip = trip;
        self.startLabel.text = passengerTrip.start;
        self.endLabel.text = passengerTrip.end;
        self.nameLabel.text = passengerTrip.passenger.nickname;
        self.timeLabel.text = passengerTrip.time;
        self.timeType.text = @"预约时间:";
        [self.userIcon sd_setImageWithURL:passengerTrip.passenger.iconPath placeholderImage:[UIImage imageNamed:@"头像占位"]];
//        [self.userIcon.image = [UIImage imageNamed:@"头像占位"];
    } else if ([trip isKindOfClass:[JTDriverTrip class]]) {
        JTDriverTrip *driverTrip = trip;
        self.startLabel.text = driverTrip.start;
        self.endLabel.text = driverTrip.end;
        self.nameLabel.text = driverTrip.driver.nickname;
        self.timeLabel.text = driverTrip.time;
        self.timeType.text = @"出发时间:";
        [self.userIcon sd_setImageWithURL:driverTrip.driver.iconPath placeholderImage:[UIImage imageNamed:@"头像占位"]];
    }
    
}

@end
